package logic

import (
	"context"
	"user_srv/user"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type LePinAddLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewLePinAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LePinAddLogic {
	return &LePinAddLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *LePinAddLogic) LePinAdd(req *types.LiePinAddrequest) (resp *types.Response, err error) {
	add, err := l.svcCtx.Userrpc.LiePinAdd(l.ctx, &user.LiePinAddRequest{
		UserId:        req.UserId,
		Types:         req.Types,
		Address:       req.Address,
		Money:         float32(req.Money),
		Lesson:        req.Lesson,
		Qualification: req.Qualification,
	})
	if err != nil {
		return &types.Response{
			Code:    500,
			Message: err.Error(),
			Data:    nil,
		}, nil
	}

	return &types.Response{
		Code:    200,
		Message: "发布成功",
		Data:    add,
	}, nil
}
